/* 영화관 */
$("#cinema-l").change(function() {
	$("#cinename *").remove();
	if ($("#cinema-l").val() != "") {
		var reqAjax = $.ajax({url: "cinema_loc_sel.bi", type: "POST", data: {addrkey: $("#cinema-l").val()}});
		reqAjax.done(function(result){
			$(result).appendTo("#cinename");
		});
		reqAjax.fail(function (jqXHR, status){
			alert("error : " + status);
		});
	} else {
		alert("영화관 지역을 입력하세요");
	}
});

/* 상영 정보 등록 */
$("#addbtn").click(function(){
	chVals();
});
var cnt = 0;
function chVals(){
	var title = $("#title option:selected").text();
	var cinename = $("#cinename option:selected").text();
	var shdate = $("#playdate").val();
	var shtime = $("#shtime-h").val() + " : " + $("#shtime-m").val();
	
	var movno = $("#title").val();
	var cno = $("#cinename").val();
	
	var str = "<tr>"
		+ "<td><input type='checkbox' class='chk' /></td>"
		+ "<td>"+title+"</td><td>"+cinename+"</td><td>"+shdate+"</td><td>"+shtime+"</td>"
		+ "<td><button type='button' class='btn btn-warning deletebtn'>삭제</button>"
		+ "<input type='hidden' name='hinfo' class='hinfo' value='" +
		+ movno + "/" + cno	+ "/" + shdate + "/" + shtime + "' /></td>"
		+ "</tr>";
	
	var isInput = $("#title").val() != "n"
				&& $("#cinema-l").val() != "n"
				&& $("#cinename").val() != "n"
				&& shdate != ""
				&& $("#shtime-h").val() != ""
				&& $("#shtime-m").val() != "";
	if (isInput) {
		$("#shinfo-tbody").append(str);
		$(".deletebtn").click(function(){	
			$(this).parent().parent().remove();
		});
		$("#okbtn").removeAttr("disabled");
	} else {
		alert("정보를 입력하세요");
	}
	
}

